<?xml version="1.0" encoding="UTF-8"?>
<!--=======================================================================
	Copyright:	umlungu consulting (pty) ltd
	Author:		Alan Benington
	Started:	2008-06-14
	Status:		release	
	Version:	2.0.0
	Build:		20080614
	License:	GNU General Public License
	======================================================================= -->

<!--=======================================================================
	Development Notes:
	==================
	20080614:	Initial release.
	=======================================================================	-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
	<!-- flag variables -->
	<xsl:variable name="want_cssref">yes</xsl:variable>

	<xsl:variable name="googleID">UA-298084-XX</xsl:variable>
	<xsl:variable name="jquery">1.2.6</xsl:variable>
	<xsl:variable name="min">.min</xsl:variable>

	<!-- Some parameters and variable declarations for compatibility -->
	<xsl:variable name="name_grp">FormX</xsl:variable>
	<xsl:variable name="device"></xsl:variable>

	<xsl:include href="baseX.xsl"/>
	<xsl:include href="blogX.xsl"/>

	<xsl:param name="base"><xsl:value-of select="$site"/>default.aspx</xsl:param>
	<xsl:variable name="BaseLinkUrl"><xsl:value-of select="$base"/>?link=</xsl:variable>
	<xsl:variable name="SecureUrl">https://./</xsl:variable>
	<xsl:variable name="ServerUrl">http://./</xsl:variable>

	
<!--======================================================================
	General templates specific to all thoughtspaces in this implementation
	====================================================================== -->
	<xsl:include href="menus.xsl"/>
	<xsl:include href="content.xsl"/>
	<xsl:include href="forms.xsl"/>
	<xsl:include href="profile.xsl"/>
	<xsl:include href="reports.xsl"/>
	<xsl:include href="shop.xsl"/>
	
	<!--=======================
	Match templates section
	======================= -->

<!--=======================
	Named templates section
	======================= -->
	
	<xsl:template name="Header">
		<div id="top">
			<xsl:apply-templates select="website/menus"/>
		</div>
	</xsl:template>
	
	<xsl:template name="HeaderPrint">
	</xsl:template>
	
	<xsl:template name="Footer">
		<xsl:apply-templates select="website/menus/footmenu"/>
	</xsl:template>
	
<!--=========================
	Utility templates section
	========================= -->
	
	<xsl:template name="htmlHead">
		<xsl:variable name="thistopic" select="blogspace/topics/topic[@name=$topic]"/>
		<xsl:variable name="thisblog" select="blogspace/topics/topic[@name=$topic]/blogs/blog[@id=$blogs]"/>
		<head>
			<xsl:call-template name="htmlTitle">
				<xsl:with-param name="tpc" select="$thistopic"/>
				<xsl:with-param name="blg" select="$thisblog"/>
			</xsl:call-template>
			<xsl:call-template name="MetaKeywords">
				<xsl:with-param name="tpc" select="$thistopic"/>
				<xsl:with-param name="blg" select="$thisblog"/>
			</xsl:call-template>
			<xsl:call-template name="MetaDescription">
				<xsl:with-param name="tpc" select="$thistopic"/>
				<xsl:with-param name="blg" select="$thisblog"/>
			</xsl:call-template>
			<xsl:call-template name="htmlStyles"/>
			<xsl:call-template name="htmlScripts"/>
			<link rel="SHORTCUT ICON">
				<xsl:attribute name="href">
					<xsl:value-of select="$site"/><xsl:value-of select="$x_img_root"/>
					<xsl:text>favicon.ico</xsl:text>
				</xsl:attribute>
			</link>
		</head>
	</xsl:template>
	
	<xsl:template name="htmlTitle">
		<xsl:param name="tpc"/>
		<xsl:param name="blg"/>
		<title>
			<xsl:value-of select="//blogspace/title"/>
			<xsl:if test="$tpc"><xsl:text> : </xsl:text><xsl:value-of select="$tpc/text()"/></xsl:if>
			<xsl:if test="$blg/title"><xsl:text> : </xsl:text><xsl:value-of select="$blg/title"/></xsl:if>
		</title>
	</xsl:template>
	
	<xsl:template name="MetaKeywords">
		<xsl:param name="tpc"/>
		<xsl:param name="blg"/>
		<meta name="keywords">
			<xsl:attribute name="content">
				<xsl:choose>
					<xsl:when test="$blg/comments/comment[1]/text"><xsl:value-of select="$blg/comments/comment[1]/text"/></xsl:when>
					<xsl:when test="$tpc/blog"><xsl:value-of select="$tpc/blog/bloghtml"/></xsl:when>
					<xsl:otherwise><xsl:value-of select="//blogspace/text"/></xsl:otherwise>
				</xsl:choose>
			</xsl:attribute>
		</meta>
	</xsl:template>
	
	<xsl:template name="MetaDescription">
		<xsl:param name="tpc"/>
		<xsl:param name="blg"/>
		<meta name="description">
			<xsl:attribute name="content">
				<xsl:choose>
					<xsl:when test="$blg/comments/comment[1]/text"><xsl:value-of select="$blg/comments/comment[1]/title"/></xsl:when>
					<xsl:when test="$tpc/blog"><xsl:value-of select="$tpc/blog/title"/></xsl:when>
					<xsl:otherwise><xsl:value-of select="//blogspace/blog/title"/></xsl:otherwise>
				</xsl:choose>
			</xsl:attribute>
		</meta>
	</xsl:template>
	
	<xsl:template name="htmlStyles">
		<xsl:choose>
			<xsl:when test="$want_cssref='yes'">
				<link rel="stylesheet" type="text/css">
					<xsl:attribute name="href">styles/<xsl:value-of select="$name"/>.css</xsl:attribute>
				</link>
				<link rel="stylesheet" type="text/css">
					<xsl:attribute name="href">styles/<xsl:value-of select="$name"/>/<xsl:value-of select="$name"/>.css</xsl:attribute>
				</link>
				<xsl:if test="descendant::grpform">
					<link rel="stylesheet" type="text/css">
						<xsl:attribute name="href">
							<xsl:text>styles/reports.css</xsl:text>
						</xsl:attribute>
					</link>
				</xsl:if>
			</xsl:when>
			<xsl:otherwise>
				<style type="text/css">
					<xsl:attribute name="title"><xsl:value-of select="$name"/> website styles</xsl:attribute>
					<xsl:comment>
						<xsl:text disable-output-escaping="yes">
body,span,table,col,h1,h2,h3,h4,tr,th,td,input,p,textarea,ul,div,textarea{color:#333333;font-family:Verdana;font-size:1.0em;}
body{padding:0px;margin:0px;font-size:80%;}
iframe{border:0px;width:300px;}
h1{font-size:2.0em;}
h2{font-size:1.7em;}
h3{font-size:1.4em;}
h4{font-size:1.1em;}
#header{float:left;background-color:#DDD;}
#content{float:left;}
#relinfo{background-color:#FFF;}
						</xsl:text>
					</xsl:comment>
				</style>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template name="htmlScripts">
		<xsl:if test="$jquery != ''">
			<xsl:choose>
				<xsl:when test="$WantGoogleJsApi='yes'">
					<script src="http://www.google.com/jsapi">
						<xsl:call-template name="nobrspace"/>
					</script>
					<script type="text/javascript">
						<xsl:text>google.load("jquery", "</xsl:text>
						<xsl:value-of select="$jquery"/>
						<xsl:text>");</xsl:text>
					</script>
				</xsl:when>
				<xsl:otherwise>
					<script type="text/javascript">
						<xsl:attribute name="src">
							<xsl:value-of select="$site"/>
							<xsl:text>scripts/jquery-</xsl:text>
							<xsl:value-of select="$jquery"/>
							<xsl:value-of select="$min"/>
							<xsl:text>.js</xsl:text>
						</xsl:attribute>
						<xsl:call-template name="nobrspace"/>
					</script>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:if>
		<script type="text/javascript">
			<xsl:attribute name="src">
				<xsl:value-of select="$site"/>
				<xsl:text>scripts/</xsl:text>
				<xsl:value-of select="$name"/>
				<xsl:text>.js</xsl:text>
			</xsl:attribute>
			<xsl:call-template name="nobrspace"/>
		</script>
		<xsl:if test="page/fields or relinfo">
			<script type="text/javascript">
				<xsl:attribute name="src">
					<xsl:value-of select="$site"/>
					<xsl:text>scripts/</xsl:text>
					<xsl:value-of select="$name"/>
					<xsl:text>Form.js</xsl:text>
				</xsl:attribute>
				<xsl:call-template name="nobrspace"/>
			</script>
		</xsl:if>
		<script type="text/javascript">
			<xsl:attribute name="src">
				<xsl:value-of select="$site"/>
				<xsl:text>scripts/</xsl:text>
				<xsl:value-of select="$name"/>
				<xsl:text>/</xsl:text>
				<xsl:value-of select="$name"/>
				<xsl:text>.js</xsl:text>
			</xsl:attribute>
			<xsl:call-template name="nobrspace"/>
		</script>
		<xsl:if test="page/flash">
			<script type="text/javascript" src="scripts/swfobject.js">
				<xsl:call-template name="nobrspace"/>
			</script>
		</xsl:if>
		<xsl:if test="$WantGoogle != 'no'">
			<xsl:call-template name="GoogleTrack"/>
		</xsl:if>

	</xsl:template>

	<xsl:template name="GoogleTrack">
		<xsl:if test="$googleID != ''">
			<script type="text/javascript">
				var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
				document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
			</script>
			<script type="text/javascript">
				var pageTracker = _gat._getTracker("<xsl:value-of select="$googleID"/>");
				pageTracker._initData();
				pageTracker._trackPageview();
			</script>
		</xsl:if>
	</xsl:template>

	<xsl:template name="CapsFirstChar">
		<xsl:param name="this_chars" />
		<xsl:value-of select="translate(substring($this_chars, 1, 1), 'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
		<xsl:value-of select="translate(substring($this_chars, 2), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>
	</xsl:template>
	
	<xsl:template match="break">
		<br/>
	</xsl:template>
	
</xsl:stylesheet>
